package com.example.hms.controller;

import com.example.hms.entity.Room;
import com.example.hms.service.RoomService;
import com.example.hms.util.Result;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/room")
public class RoomController {
    @Resource
    private RoomService roomService;

    @RequestMapping(value = "selectAllRoom", method = RequestMethod.GET)
    public Result selectAllRoom(String roomNumber, String roomTypeName, String roomId) {
        return roomService.selectAllRoom(roomNumber, roomTypeName, roomId);
    }

    @RequestMapping(value = "insert", method = RequestMethod.GET)
    public Result insert(Room room, HttpServletRequest request) {
        // 调用roomService的insert方法，并传入房间对象
        return roomService.insert(room,request);
    }

    @RequestMapping(value = "update", method = RequestMethod.GET)
    public Result update(Room room, HttpServletRequest request) {
        // 调用roomService的update方法，并传入房间对象
        return roomService.update(room,request);
    }

    @RequestMapping(value = "delete", method = RequestMethod.GET)
    public Result delete(Room room, HttpServletRequest request) {
        // 调用roomService的delete方法，并传入房间对象
        return roomService.delete(room,request);
    }
}
